package com.wn32.main.demo;

import java.util.*;

public class Demo1 {
    public static void main(String[] args) {
        String[] arr={"冯琦","张三","李四","冯琦","王五","赵六","冯琦","赵六","赵六","赵六","赵六","冯琦"};
        HashMap<String, Integer> map = new HashMap<>();
        for (String s : arr) {
         if(!map.containsKey(s)){
             map.put(s,1);
         }else{
             int i = map.get(s) + 1;
             map.put(s,i);
         }
        }
     map.entrySet().stream().sorted((o1, o2) -> {
         return o1.getValue()-o2.getValue();
     }).forEach(System.out::println);
    }
}
